package com.foton.bigdatastudy.wordcount;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author RenPu
 * @Date 2023/8/21 16:54
 * @Version 1.0
 * @Description: reduce ：任务计算
 **/
public class WordCountReduce extends Reducer<Text, IntWritable,Text,IntWritable> {

    private IntWritable count=new IntWritable();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {

        int sum=0;

        for (IntWritable value:values){
            sum+=value.get();
            count.set(sum);
        }

        context.write(key,count);

    }
}
